package com.ease.map.handler.feature.draw {
    import com.ease.map.Map;
    import com.ease.map.common.enum.HandlerEnum;
    import com.ease.map.handler.feature.draw.AbstractDrawHandler;
    import com.ease.map.handler.feature.draw.DrawLineHandler;
    import com.ease.map.handler.feature.draw.DrawPointHandler;
    import com.ease.map.handler.feature.draw.DrawPolygonHandler;
    import com.ease.map.layer.FeatureLayer;
    
    import mx.collections.ArrayCollection;

    /**
     * 编辑工具
     * */
    public class DrawHandler {
        private var _map:Map;
        private var handler:AbstractDrawHandler;
        //可捕捉的图层idsW
        private var _snapClickCallback:Function = null;
        public static const DRAW_POINT:int = 1;
        public static const DRAW_LINE:int = 2;
        public static const DRAW_POLYGON:int = 3;
        private var _drawLayer:FeatureLayer;

        public function DrawHandler(map:Map, drawType:int) {
            _map = map;
            switch (drawType) {
                case DrawHandler.DRAW_POINT:
                    handler = map.getHandler(HandlerEnum.DRAW_POINT_HANDLER) as DrawPointHandler;
                    break;
                case DrawHandler.DRAW_LINE:
                    handler = map.getHandler(HandlerEnum.DRAW_LINE_HANDLER) as DrawLineHandler;
                    break;
                case DrawHandler.DRAW_POLYGON:
                    handler = map.getHandler(HandlerEnum.DRAW_POLYGON_HANDLER) as DrawPolygonHandler;
                    break;
            }
        }

        public function set active(value:Boolean):void {
            handler.active = value;
            if (value) {

            }
            else {
                //删除黑板
            }
        }

        public function set drawLayer(value:FeatureLayer):void {
            handler.drawLayer = value;
            this._drawLayer = value;
        }

        public function get drawLayer():FeatureLayer {
            return this._drawLayer;
        }

        public function set snapLayerIds(value:ArrayCollection):void {
            handler.snapLayerIds = value;
        }

        public function set snapClickCallback(value:Function):void {
            handler.snapClickCallback = value;
        }

        public function get snapLayerIds():ArrayCollection {
			return handler.snapLayerIds;
        }

        public function set backToPreviouCallback(value:Function):void {
            handler.backToPreviouCallback = value;
        }

        public function set mouseDoubleClickEndEnabled(value:Boolean):void {
            handler.dbclickEnabled = value;
        }

    }
}